home *** CD-ROM | disk | FTP | other *** search
- Path: thor.tu.hac.com!collins
- From: collins@thor.tu.hac.com (Ron Collins)
- Newsgroups: comp.lang.c
- Subject: Re: Do you have ever pass structures?
- Date: 27 Feb 1996 18:54:46 GMT
- Organization: Advanced Depot Systems
- Message-ID: <4gvk1m$8sa@hacgate2.hac.com>
- References: <4ge8mi$qjm@srvr1.engin.umich.edu> <4ggsio$343@news-f.iadfw.net> <4gqk11$e7l@airdmhor.gen.nz> <4gtm62$gjb@sam.inforamp.net>
- NNTP-Posting-Host: thor.tu.hac.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Lew Pitcher (pitchl@tdbank.ca) wrote:
- : gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
-
- : >Adam Peterson:
- : >> The *disadvantage* is speed and space. Passing a pointer is just
- : >> word//double word. Passing the actual structure requires loading the
- : >> stack with all the elements of the structure...slow...
-
- : > But once it's done you don't have this pointer-thing to dereference all
- : >the time (of course, this depends on how much register space you have - will
- : >I ever get over my Intelesque hangups?).
-
- : Yah, but you still wind up dereferencing a pointer (just this time
- : it's the stack pointer).
-
- No ... if I pass a structure on the stack, _I_ never have to dereference
- a pointer at all. The compiler will do that for me.
-
- : If you really want efficiency, then define a
- : global structure variable, put your data into it, and let the called
- : function access it directly. There should be less pointer
- : dereferencing that way.
-
- What -- you don't think the compiler generates a pointer to a global area,
- the same as it does to a stack or heap object?
-
-
- -- Collins --
-
- -----
- The views expressed here are mine alone.
-
- Ron Collins/Hughes Aircraft Company/M20,P20/Tucson Az 85706
- rcollins@thor.tu.hac.com collins@seagull.rtd.com
- ยก----
-